package com.micro.frog.job.rest;

import com.micro.frog.core.common.PageResult;
import com.micro.frog.core.common.Result;
import com.micro.frog.job.model.dto.JobLogDTO;
import com.micro.frog.job.service.JobLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author :  ljh
 * @date : 2018/5/10
 **/
@Slf4j
@RestController
@RequestMapping(value = "/taskLog")
public class JobLogController {

    @Autowired
    JobLogService jobLogService;

    @GetMapping(value = "/all")
    public Result all() {
        Result result = new Result();
        try {
            result.setFlag(true);
            result.setData(jobLogService.all());
        } catch (Exception e) {
            result.setCode("20000");
            result.setMsg("系统异常" + e.getMessage());
            log.error("系统异常，e={}", e);
        }
        return result;
    }

    @GetMapping(value = "/list")
    public PageResult list(JobLogDTO taskLogDTO) {
        PageResult result = new PageResult();
        try {
            result = jobLogService.listPage(taskLogDTO);
        } catch (Exception e) {
            result.setCode("20000");
            result.setMsg("系统异常");
            log.error("系统异常，e={}", e);
        }
        return result;
    }
}
